package com.futures.investm.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.futures.investm.R;
import com.futures.investm.entity.CalendarItem;

import java.util.ArrayList;

import tech.com.commoncore.utils.DataUtils;

public class CalendarListAdapter extends BaseQuickAdapter<CalendarItem, BaseViewHolder> {

    public CalendarListAdapter() {
        super(R.layout.item_calendar_choiceness, new ArrayList<CalendarItem>());
    }

    @Override
    protected void convert(BaseViewHolder helper, CalendarItem item) {



        helper.setText(R.id.tv_time, item.predicttime);
        helper.setText(R.id.tv_content, item.title);
        helper.setRating(R.id.rating_bar, item.importance);
        helper.setText(R.id.tv_former_value, "前值：" + (DataUtils.isEmptyString(item.previous) ? "" : item.previous));
        helper.setText(R.id.tv_expected, "预期：" + (DataUtils.isEmptyString(item.forecast) ? "" : item.forecast));
        helper.setText(R.id.tv_announce, "公布：" + (DataUtils.isEmptyString(item.reality) ? "" : item.reality));

        ImageView view = helper.getView(R.id.iv_national_flag);
        if (item.country.equals("美国")){
            Glide.with(mContext).load(R.mipmap.img_flag_america).into(view);
        }
        if (item.country.equals("澳大利亚")){
            Glide.with(mContext).load(R.mipmap.img_flag_australia).into(view);
        }
        if (item.country.equals("智利")){
            Glide.with(mContext).load(R.mipmap.img_flag_brazil).into(view);
        }
        if (item.country.equals("加拿大")){
            Glide.with(mContext).load(R.mipmap.img_flag_canada).into(view);
        }
        if (item.country.equals("中国")){
            Glide.with(mContext).load(R.mipmap.img_flag_chain).into(view);
        }
        if (item.country.equals("英国")){
            Glide.with(mContext).load(R.mipmap.img_flag_england).into(view);
        }
        if (item.country.equals("法国")){
            Glide.with(mContext).load(R.mipmap.img_flag_french).into(view);
        }
        if (item.country.equals("德国")){
            Glide.with(mContext).load(R.mipmap.img_flag_germany).into(view);
        }
        if (item.country.equals("日本")){
            Glide.with(mContext).load(R.mipmap.img_flag_japan).into(view);
        }
        if (item.country.equals("韩国")){
            Glide.with(mContext).load(R.mipmap.img_flag_korea).into(view);
        }
        if (item.country.equals("瑞典")){
            Glide.with(mContext).load(R.mipmap.img_flag_swiss).into(view);
        }

    }
}
